package com.hqq.http;

/**
 * RequestMethod
 * 请求方法枚举类
 * Created by heqianqian on 2017/7/21.
 */
public enum RequestMethod {

    POST("POST"), GET("GET"), DELETE("DELETE"), PUSH("PUSH");

    RequestMethod(String name) {
        this.name = name;
    }

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据请求方法名获得指定的枚举类型
     */
    public static RequestMethod getRequestMethod(String requestMethodName) {
        for (RequestMethod requestMethod : RequestMethod.values()) {
            if (requestMethod.getName().endsWith(requestMethodName)) {
                return requestMethod;
            }
        }
        return null;
    }
}